import {configureStore} from '@reduxjs/toolkit'
import auth from './modules/auth'
//1、导入routerMiddleware
import {routerMiddleware} from 'react-router-redux';
//2、导入createBrowserHistory
import {createBrowserHistory} from 'history'
//3、调用createBrowserHistory方法
const browserHistory=createBrowserHistory()
//4、调用routerMiddleware创建中间件对象
const middleware = routerMiddleware(browserHistory)
const store=configureStore({
    reducer:{
        auth
    },
    middleware:(getDefaultMiddleware)=>getDefaultMiddleware({serializableCheck:false}).concat(middleware)
})
// Infer the `RootState` and `AppDispatch` types from the store itself
export type RootState = ReturnType<typeof store.getState>
// Inferred type: {posts: PostsState, comments: CommentsState, users: UsersState}
export type AppDispatch = typeof store.dispatch
export default store